package com.yztc.yidoutang.activity.daren_activity;

import com.yztc.yidoutang.bean.DaRenBean;
import com.yztc.yidoutang.http.DaRenService;
import com.yztc.yidoutang.http.HttpHelper;

import java.util.Map;

import retrofit2.Retrofit;
import rx.Observable;
import rx.Observer;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by My on 2016/10/19.
 */

public class DaRenModel implements DaRenContract.Model {
    @Override
    public void getDaRenData(Map<String, String> params, final DaRenContract.OnLoadDaRenListener loadDaRenListener) {
        Retrofit retrofit= HttpHelper.getInstance().getRetrofit();
        Observable<DaRenBean> observable=retrofit.create(DaRenService.class).getDaRenList(params);
        observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<DaRenBean>() {
            @Override
            public void onCompleted() {

            }

            @Override
            public void onError(Throwable e) {

            }

            @Override
            public void onNext(DaRenBean daRenBean) {
                loadDaRenListener.onSuccess(daRenBean);
            }
        });
    }
}
